package com.zegome.demo;

import aurelienribon.tweenengine.BaseTween;
import aurelienribon.tweenengine.TweenCallback;

import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.Texture.TextureFilter;
import com.badlogic.gdx.graphics.g2d.BitmapFont;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.badlogic.gdx.scenes.scene2d.InputEvent;
import com.badlogic.gdx.scenes.scene2d.utils.ClickListener;
import com.zegome.uis.TimelineTemplate;
import com.zegome.uis.ZButton;
import com.zegome.uis.ZGame;
import com.zegome.uis.ZScreen;
import com.zegome.uis.ZTextButton;

public class DemoScreen extends ZScreen{

	private Texture button = new Texture(Gdx.files.internal("data/button.png"));
	private Texture bg = new Texture(Gdx.files.internal("data/background.png"));
	private ZButton batdau;
	private ZTextButton thoat;
	
	public DemoScreen(ZGame mGame) {
		super(mGame);
		init();
	}

	private void init() {
		
		batdau = new ZButton(new TextureRegion(button), new TextureRegion(button));
		batdau.setPosition(game.getDefWidth()/2-batdau.getWidth()/2, 300);
		TimelineTemplate.AppearZoomOut(batdau, 2f, 0.5f).start(getManager());
		batdau.addListener(new ClickListener(){
			@Override
			public void clicked(InputEvent event, float x, float y) {
				TimelineTemplate.DisappearZoomLitteOut(batdau, 0.2f)
					.setCallback(new TweenCallback() {
						@Override
						public void onEvent(int type, BaseTween<?> source) {
							TimelineTemplate.ResetActor(batdau, getManager());
							System.out.println("BatDau Clicked!");
						}
					}).start(getManager());
			}
		});
		Texture fontTexture = new Texture(Gdx.files.internal("data/font.png")); fontTexture.setFilter(TextureFilter.Linear, TextureFilter.Linear);
		BitmapFont font = new BitmapFont(Gdx.files.internal("data/font.fnt"),new TextureRegion(fontTexture), false);
		thoat = new ZTextButton("thoat", font,new TextureRegion(button), new TextureRegion(button));
		thoat.setPosition(game.getDefWidth()/2-thoat.getWidth()/2, 100);
		TimelineTemplate.AppearZoomIn(thoat, 2.5f, 0.5f).start(getManager());
		thoat.addListener(new ClickListener(){
			@Override
			public void clicked(InputEvent event, float x, float y) {
				System.out.println("Thoat clicked!");
			}
		});
		
		stage.addActor(batdau);
		stage.addActor(thoat);
	}

	@Override
	public void resize(int width, int height) {
		
	}

	@Override
	public void show() {
		
	}

	@Override
	public void hide() {
		
	}

	@Override
	public void pause() {
		
	}

	@Override
	public void resume() {
		
	}

	@Override
	public void update(float delta) {
		
	}

	@Override
	public void draw() {
		batch.draw(bg, 0, 0);
	}

}
